Date.prototype.format = function(format) {
	var o = {
		"M+" : this.getMonth() + 1, // month
		"d+" : this.getDate(), // day
		"h+" : this.getHours(), // hour
		"m+" : this.getMinutes(), // minute
		"s+" : this.getSeconds(), // second
		"q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
		"S" : this.getMilliseconds()
	// millisecond
	}

	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "")
				.substr(4 - RegExp.$1.length));
	}

	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
					: ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;
};

//验证身份证的日期性别

function checkCardNo(num){
	var len, re; 
	len = num.length; 
	if (len == 15) 
	{ 
		re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/); 
		var arrSplit = num.match(re); 
		//检查生日日期是否正确 
		var dtmBirth = new Date('19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]); 
		var bGoodDay; 
		bGoodDay = (dtmBirth.getYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4])); 
		if (!bGoodDay) 
		{   
			$("#cardSafety_error").html("请输入正确身份证号");
		    return false; 
		} 
		else 
		{ 
		//将15位身份证转成18位 
		//校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
		    var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); 
		    var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); 
		    var nTemp = 0, i;   
		    num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6); 
		    for(i = 0; i < 17; i++) 
		    { 
		        nTemp += num.substr(i, 1) * arrInt[i]; 
		    } 
		    num += arrCh[nTemp % 11];   
		    return true;   
		}
		
	} 
	if (len == 18) 
	{
		re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/); 
		var arrSplit = num.match(re);
		//检查生日日期是否正确 
		var dtmBirth = new Date(arrSplit[2] + "/" + arrSplit[3] + "/" + arrSplit[4]); 
		var bGoodDay; 
		bGoodDay = (dtmBirth.getFullYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4])); 
	
		if (!bGoodDay) 
		{ 
			$("#cardSafety_error").html("请输入正确身份证号");
			return false; 
		} 
		else 
		{
			//检验18位身份证的校验码是否正确。 
			//校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
			var valnum; 
			var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); 
			var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); 
			var nTemp = 0, i; 
			for(i = 0; i < 17; i++) 
			{ 
				nTemp += num.substr(i, 1) * arrInt[i]; 
			} 
			valnum = arrCh[nTemp % 11]; 
			if (valnum != num.substr(17, 1)) 
			{ 
				$("#cardSafety_error").html("请输入正确身份证号");
				return false; 
			}
			//判断年龄是否满18岁
			var UUserCard = arrSplit[2]+"-"+arrSplit[3]+"-"+arrSplit[4];
			var myDate = new Date(); 
			var month = myDate.getMonth() + 1; 
			var day = myDate.getDate(); 
			var age = myDate.getFullYear() - UUserCard.substring(0, 4) - 1; 
			if (UUserCard.substring(5, 7) < month || UUserCard.substring(5, 7) == month && UUserCard.substring(8) <= day) { 
				age = age + 1; 
			} 
			if(age < 18){
				$("#cardSafety_error").html("此身份证号未满18周岁");
				return false;
			}
			return true; 
		} 
	} 
	return false; 
}

/**
 * 对数据进行保留两位小数处理,带千分符
 */
function interceptDecimal(inputData){
	if(inputData==null||inputData==''||inputData=='undefined'){
		return "0.00";
	}
	var dealData = inputData+"";
	var pointIndex = dealData.indexOf('.');
	var result = "";
    
	if(pointIndex == -1 || pointIndex == dealData.length-2){//没有小数或只有一位小数时
		result =  inputData.toFixed(2) + "";
	}else{//两位或两位以上小数时
		//result = ~~(inputData * 100) / 100 + "";
		result = dealData.substring(0,pointIndex+3);
	}
	var _pIndex = result.indexOf('.');
	var intPart = (result.substr(0,_pIndex)).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
	var decPart = result.substr(_pIndex,result.length);
	return intPart + decPart;
}


/**
 * 对数据进行保留两位小数处理,不用逗号分开！
 */
function interceptDecimals(inputData){
	if(inputData==null||inputData==''||inputData=='undefined'){
		return "0.00";
	}
	var dealData = inputData+"";
	var pointIndex = dealData.indexOf('.');
	var result = "";
  
	if(pointIndex == -1 || pointIndex == dealData.length-2){//没有小数或只有一位小数时
		result =  inputData.toFixed(2) + "";
	}else{//两位或两位以上小数时
		//result = ~~(inputData * 100) / 100 + "";
		result = dealData.substring(0,pointIndex+3);
	}
	
	return result;
}

function patternNumber(orgAcc){
	orgAcc = orgAcc.toFixed(2);
	orgAcc = orgAcc +"";
	var deciAcc = orgAcc.split(".");
	if(deciAcc.length == 1) return orgAcc;
	var orgAccNum = Number(orgAcc);
	orgAcc = orgAccNum.toFixed(2)+"";
	var deciAcc2 = orgAcc.split(".");
	var zsPart = deciAcc[0];
	var zslen = zsPart.length;
	var tarlen = zslen - zslen%3;
	var ndou = tarlen / 3;
	if(ndou < 1 || (ndou ==1 && zslen%3 == 0)) return orgAcc;
	var tarStr = zsPart.substring(0, zslen%3);
	var syStr = zsPart.substring(zslen%3, zsPart.length);
	for(var i=1; i<= ndou; i++){
		tarStr = tarStr + "," + syStr.substring(0, 3);
		syStr = syStr.substring(3, syStr.length);
	}
	if(zslen%3 == 0){
		tarStr = tarStr.substring(1, tarStr.length);
	}
	return tarStr + "." + deciAcc2[1];
}

/*back to top*/
var scrolltotop={
	setting:{
		startline:100, //起始行
		scrollto:0, //滚动到指定位置
		scrollduration:400, //滚动过渡时间
		fadeduration:[500,100] //淡出淡现消失
	},
	controlHTML:'<a href="javascript:void(0)" class="topup"></a>', //返回顶部按钮
	controlattrs:{offsetx:30,offsety:50},//返回按钮固定位置
	anchorkeyword:"#top",
	state:{
		isvisible:false,
		shouldvisible:false
	},scrollup:function(){
		if(!this.cssfixedsupport){
			this.$control.css({opacity:0});
		}
		var dest=isNaN(this.setting.scrollto)?this.setting.scrollto:parseInt(this.setting.scrollto);
		if(typeof dest=="string"&&jQuery("#"+dest).length==1){
			dest=jQuery("#"+dest).offset().top;
		}else{
			dest=0;
		}
		this.$body.animate({scrollTop:dest},this.setting.scrollduration);
	},keepfixed:function(){
		var $window=jQuery(window);
		var controlx=$window.scrollLeft()+$window.width()-this.$control.width()-this.controlattrs.offsetx;
		var controly=$window.scrollTop()+$window.height()-this.$control.height()-this.controlattrs.offsety;
		this.$control.css({left:controlx+"px",top:controly+"px"});
	},togglecontrol:function(){
		var scrolltop=jQuery(window).scrollTop();
		if(!this.cssfixedsupport){
			this.keepfixed();
		}
		this.state.shouldvisible=(scrolltop>=this.setting.startline)?true:false;
		if(this.state.shouldvisible&&!this.state.isvisible){
			this.$control.stop().animate({opacity:1},this.setting.fadeduration[0]);
			this.state.isvisible=true;
		}else{
			if(this.state.shouldvisible==false&&this.state.isvisible){
				this.$control.stop().animate({opacity:0},this.setting.fadeduration[1]);
				this.state.isvisible=false;
			}
		}
	},init:function(){
		jQuery(document).ready(function($){
			var mainobj=scrolltotop;
			var iebrws=document.all;
			mainobj.cssfixedsupport=!iebrws||iebrws&&document.compatMode=="CSS1Compat"&&window.XMLHttpRequest;
			mainobj.$body=(window.opera)?(document.compatMode=="CSS1Compat"?$("html"):$("body")):$("html,body");
			mainobj.$control=$('<div id="topcontrol">'+mainobj.controlHTML+"</div>").css({position:mainobj.cssfixedsupport?"fixed":"absolute",bottom:mainobj.controlattrs.offsety,right:mainobj.controlattrs.offsetx,opacity:0,cursor:"pointer"}).attr({title:""}).click(function(){mainobj.scrollup();return false;}).appendTo("body");if(document.all&&!window.XMLHttpRequest&&mainobj.$control.text()!=""){mainobj.$control.css({width:mainobj.$control.width()});}mainobj.togglecontrol();
			$('a[href="'+mainobj.anchorkeyword+'"]').click(function(){mainobj.scrollup();return false;});
			$(window).bind("scroll resize",function(e){mainobj.togglecontrol();});
		});
	}
};
/*back to top end of*/